package com.spark.lola.controller.logistics;

import com.spark.lola.logistics.constant.LogisticsConstant;
import com.spark.lola.logistics.entity.CarInfo;
import com.spark.lola.logistics.service.CarInfoService;
import com.spark.lola.support.common.entity.ShiroUser;
import com.spark.lola.support.common.util.ResponseBean;
import com.spark.lola.support.wms.cache.CollectionCache;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: Zhi-peng wang
 * @date: 2020/05/25 15:03
 **/
@RestController
@RequestMapping(value = "/api/logistics/car", produces = "application/json;charset=utf-8")
@Api(value = "/api/logistics/car", tags = "车辆信息接口")
public class CarController {

    @Autowired
    private CarInfoService carInfoService;

    @ApiOperation(value = "获取车辆列表")
    @ApiImplicitParam(name = "key", value = "模糊查询字段，查询车牌", required = true, dataType = "String", paramType = "query")
    @RequestMapping(value = "/map", method = RequestMethod.POST)
    public ResponseBean map(@RequestParam(required = false) String key) {
        return ResponseBean.success(carInfoService.selectMap(key, null));
    }

    @ApiOperation(value = "获取车辆信息详情")
    @ApiImplicitParam(name = "carId", value = "车辆信息id", required = true, dataType = "long", paramType = "path")
    @RequestMapping(value = "/findInfo/{carId}", method = RequestMethod.POST)
    public ResponseBean findInfo(@PathVariable long carId) {
        CarInfo carInfo = new CarInfo();
        if (carId != 0) {
            carInfo = carInfoService.getById(carId);
        }
        return ResponseBean.success(carInfo);
    }

}
